package com.wawayaya.bookreader.ViewPages;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewPager extends android.support.v4.view.ViewPager {

	private boolean m_bscrollable = true;
	
	public CustomViewPager(Context context) {
		super(context);
		this.setOffscreenPageLimit(1);
	}
	public CustomViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.setOffscreenPageLimit(1);
	}
	
	public void setscrollable(boolean bscrollable) {
		m_bscrollable = bscrollable;
	}
	
	@Override
    public boolean onTouchEvent(MotionEvent ev) {
       if(!m_bscrollable) {
            return false;
        } else {
            return super.onTouchEvent(ev);
        }
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if(!m_bscrollable) {
            return false;
        } else {
            return super.onInterceptTouchEvent(ev);
        }
    }

}
